'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var departmentModel = baseController.getBaseDocFields();
departmentModel.Code = {
    type: String,
    trim: true
};

departmentModel.Name = {
    type: String,
    trim: true
};

departmentModel.IsEffective = {
    type: Boolean
};

departmentModel.Remark = {
    type: String,
    default: '',
    trim: true
};

var departmentSchema = new Schema(departmentModel);
departmentSchema.index({Name: 1});
departmentSchema.index({Code: 1}, {"unique": true});
departmentSchema.index({Code: "text", Name: "text", Remark: "text"});

mongoose.model('Department', departmentSchema, 'Department');
